package com.yf1706.bean;

import java.io.Serializable;
import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;


/**
 * The persistent class for the dep database table.
 * 
 */
@Entity
@NamedQuery(name="Dep.findAll", query="SELECT d FROM Dep d")
public class Dep implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="dep_id")
	private int depId;
	
	private String depNum;

	@Column(name="dep_name")
	private String depName;

	private String remark;

	//bi-directional many-to-one association to Dep
	@ManyToOne
	@JsonIgnore
	@JoinColumn(name="higher_dep_id")
	@JSONField(serialize = false)
	private Dep dep;


	//bi-directional many-to-one association to Emp
	@OneToMany(mappedBy="dep")
	@JsonIgnore
	@JSONField(serialize = false) 
	private List<Emp> emps;

	@OneToOne(mappedBy="dep")
	@JsonIgnore
	@JSONField(serialize = false) 
	private QuestionBank qb;
	
	public QuestionBank getQb() {
		return qb;
	}

	public void setQb(QuestionBank qb) {
		this.qb = qb;
	}

	public Dep() {
	}

	@Override
	public String toString() {
		return "Dep [depId=" + depId + ", depNum=" + depNum + ", depName=" + depName + ", remark=" + remark + ", dep="
				+ dep +  ", emps=" + emps + ", qb=" + qb + "]";
	}

	public int getDepId() {
		return this.depId;
	}

	public void setDepId(int depId) {
		this.depId = depId;
	}

	public String getDepName() {
		return this.depName;
	}

	public void setDepName(String depName) {
		this.depName = depName;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getDepNum() {
		return depNum;
	}

	public void setDepNum(String depNum) {
		this.depNum = depNum;
	}

	public Dep getDep() {
		return this.dep;
	}

	public void setDep(Dep dep) {
		this.dep = dep;
	}



	public List<Emp> getEmps() {
		return this.emps;
	}

	public void setEmps(List<Emp> emps) {
		this.emps = emps;
	}

	public Emp addEmp(Emp emp) {
		getEmps().add(emp);
		emp.setDep(this);

		return emp;
	}

	public Emp removeEmp(Emp emp) {
		getEmps().remove(emp);
		emp.setDep(null);

		return emp;
	}

}